var li = document.getElementsByTagName("li");
var tab = document.getElementsByClassName("tab");
for (let index = 0; index < li.length; index++) {
    li[index].no=index; 
}
function viewDetails (e){
    let that = e.target
    console.log(that);
    //获取金山词霸的相关单词
    axios.get("http://dict.iciba.com/dictionary/word/suggestion?word="+that.innerText)
        .then(function (response){
            let data = response.data.message[0];
            console.log(response);
            word.title=data.key;
            word.explain=data.paraphrase;
        })
    //显示单词预览框
    document.getElementById("cover").style.display="";
    document.getElementById("word-detail").style.display="";
}
window.onload=function (){
    var info = new Vue({
        el:'#info',
        data:{
            bookTitle:"Lorem ipsum dolor sit amet",
            undisposed: ["test","lorem"],
            execute:["dolor","sit","amet"],
            familiar:["consectetur","adipiscing","elit"]
        }
    });
    //获取单词
    axios.get("/getWordHistory?book="+request("book"))
        .then(function (response){
            let data = response.data;
            info.undisposed = data.word;
            info.execute =data.execute;
            info.familiar =data.familiar;
            info.bookTitle = data.bookTitle;
            console.log(data);

        });
    //单词详情页面关闭
    var close =document.getElementById("close");
    close.onclick =function (){
        document.getElementById("cover").style.display="none";
        document.getElementById("word-detail").style.display="none";
    }
    //遍历按钮添加点击事件
    for (let index = 0; index < li.length; index++) {
        li[index].onclick =function () {
            li[index].no=index;
            for(let y = 0; y < li.length; y++){
                tab[y].style.display="none";
                li[y].className="";
            }
            this.className="select";
            tab[this.no].style.display=""
        }
    }
}

var word = new Vue({
    el:'#word-detail',
    data:{
        title:"Lorem",
        pronounceBritain:"英[test]",
        pronounceAmerica:"美[test]",
        explain:"adj. 重大的；有效的；有意义的；值得注意的；意味深长的 n. 象征；有意义的事物 [ 比较级 more significant 最高级 most significant ] ;",
        example:["There remained one significant problem. 还有一个非常重要的问题。",
            "Your work has shown a significant improvement. 你的工作有了显著改进。",
            "The results are not statistically significant. 这些结果在统计上没有显著意义。"]
    }
});